package movee.spring.app.template.utils.network;


/**
 * bgp as工具类
 *
 * @author movee
 */
public interface BgpUtils {

    long PUBLIC_AS_2_LOWBOUND = 1L;
    long PUBLIC_AS_2_UPBOUND = 64511L;
    long PUBLIC_AS_4_LOWBOUND = 65536L;
    long PUBLIC_AS_4_UPBOUND = 41_9999_9999L;

    /**
     * 判断一个bgp as number是公网还是私网的
     * @param as as number
     * @return true or false
     */
    static boolean isPublicAs(final long as) {

        long unsignedAs = as & 0x0_FFFF_FFFFL;

        return (unsignedAs >= PUBLIC_AS_2_LOWBOUND && unsignedAs <= PUBLIC_AS_2_UPBOUND)
                || (unsignedAs >= PUBLIC_AS_4_LOWBOUND && unsignedAs <= PUBLIC_AS_4_UPBOUND);

    }

}
